<template>
	<view>
		<bsNavBar title='活动中心'></bsNavBar>
		<view class="content">
			<view class="padding30">
				<bs-swiper @handSwIndex='handSwIndex' :list='swiperList'></bs-swiper>
			</view>
			<u-tabs active-color='#0050A5' inactive-color='#9A9A9A' :list="list" :is-scroll="false" :current="current" @change="change"></u-tabs>
			<u-gap height="14" margin-top='14' bg-color="#FAFAFA "></u-gap>
			<view class="plr">
				<bsList onMsg='暂无活动' @handNavDetails='handNavDetails' :props='props' :status='status' :list='activList' :page='page'></bsList>
			</view>
		</view>
		<u-back-top :scroll-top="scrollTop"></u-back-top>
	</view>
</template>

<script>
	import bsList from '@/components/bs-list/bs-list.vue'
	export default {
		components: {
			bsList
		},
		data() {
			return {
				scrollTop: 0,
				status: 'nomore',
				activList: [],
				props: {
					title233: 'title',
					name233: 'name',
				},
				page: 0,
				list: [{
					name: '协会活动'
				}, {
					name: '活动中心'
				}],
				swiperList: [],
				current: 0,
				pages: 0,
				paging: {
					status: '4,5',
					page: 1,
					pageSize: 10,
					activityType: 0,
				}
			};
		},
		onPageScroll(e) {
			this.scrollTop = e.scrollTop;
		},
		async onLoad(e) {
			if (e.index) {
				this.current = e.index
				this.paging.activityType = e.index
			}
			await this.init()
		},
		async onReachBottom() {
			await this.getMore()
		},
		methods: {
			handSwIndex(index) {
				console.log(this.swiperList[index])
				if (this.swiperList[index].phoneImgSrc) {
					uni.navigateTo({
						url: '/pages/webView/webView?webSrc=' + this.swiperList[index].phoneImgSrc
					})
				}
			},
			async getMore() {
				if (this.pages == this.paging.page) {
					this.status = 'nomore';
					return
				}
				this.status = 'loading';
				this.paging.page = ++this.paging.page;
				let activityContent = await this.$u.api.activityContent(this.paging)
				this.pages = activityContent.pages
				this.activList = this.activList.concat(activityContent.list)
				this.status = 'loadmore';
			},
			async init() {
				let swiperList = await this.$u.api.getBanner({
					category: 11
				})
				if (swiperList.length != 0) {
					this.swiperList = swiperList[0].imgUrlList
				}
				let activityContent = await this.$u.api.activityContent(this.paging)
				this.pages = activityContent.pages
				this.activList = activityContent.list

			},
			async change(index) {
				this.paging.activityType = index
				this.paging.page = 1
				this.current = index;
				await this.init()
			},
			handNavDetails(item) {
				uni.navigateTo({
					url: '/pages/avtiveityConter/avtiveityDetails/avtiveityDetails?row=' + JSON.stringify(item)
				})
			}
		}
	}
</script>

<style lang="scss">
</style>
